package com.zhongli.devplatform.controller.sys;


import com.zhongli.devplatform.service.imp.sys.ReadAddressService;
import com.zhongli.devplatform.vo.sys.AddressVO;
import com.zhongli.devplatform.bean.Res;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.CacheManager;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/address")
public class AddressController {

    @Autowired
    private ReadAddressService addressService;

    @Autowired
    private CacheManager cacheManager;

    @Value("${dev-platform.cache-name}")
    private String cacheName;


    @RequestMapping("/list")
    public Res list() {
        List<AddressVO> addressVOList = cacheManager.getCache(cacheName + ReadAddressService.CACHE_KEY).get("list", ArrayList::new);
        return new Res(addressVOList);
    }

}
